[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  EXTEND System     Changes made to a variable may effect other variables.

  Clipper Version  1.03 dtd 09/15/90.

  Problem Statement

  When a pointer points to more than one variable and one of the variables
  is changed in an ASM or C function, the other variables may be changed.

  Work Around(s)
  a) Make a local copy of the variable and pass it to the function.
  b) Break the pointer relationship before passing the variable.

  Notes This subject is slightly over the author's head, so forgive
            the terminology <g>.
  a) The following is an abstract of a forum message on the subject:

    Fm: Pedro P. Polakoff [3PS] 73157,2412
    Here is code that will demonstrate that:

       1. _parc() returns a pointer to the actual data.
       2. cVar1:=cVar2:="Foobar" points both variables at the same
          block of memory much as a C char * does.

    CLIPPER PORTION ---
    static cVar1
    static cVar2

    function str_test
       cVar1:=cVar2:="Foobar"      // HERE IS THE ASSIGNMENT
       QOut(cVar1,cVar2)
       ChangeStr(cVar2)            // NOTE NOT PASSED BY REFERENCE
       QOut(cVar1,cVar2)
    return(NIL)

    C PORTION ---

    #include <extend.h>

    CLIPPER changestr()
    {
       char *str;
       register int p;
       byte q='A';

       if(PCOUNT==1 && ISCHAR(1)){
          str=_parc(1);           // pointer to pointer
          for(p=0;p<_parclen(1);p++){str[p]=q;}  // directly changed
       }
       _ret();                    // NIL return
    }
  b) Another example can be found in EXTBUG.ZIP in the NANFORUM LIB 17.
     Uploaded by Francois Batte 70022,3424.

See Also: CALL()*
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson